home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TOT_1.ARJ / SOURCE.EXE / arc / TOTSYS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-11  |  14KB  |  618 lines

  1. {               Copyright 1991 TechnoJock Software, Inc.               }
  2. {                          All Rights Reserved                         }
  3. {                         Restricted by License                        }
  4.  
  5. {                             Build # 1.00                             }
  6.  
  7. Unit totSYS;
  8. {$I TOTFLAGS.INC}
  9.  
  10. {
  11.  Development Notes:
  12. }
  13.  
  14. INTERFACE
  15.  
  16. uses DOS, CRT;
  17.  
  18. TYPE
  19. tVideo = (UnKnown, Mono, CGA, MCGAMono, MCGACol, EGAMono, EGACol, VGAMono, VGACol);
  20. tDate = (USA,Europe,Japan);
  21.  
  22. pDisplayOBJ = ^DisplayOBJ;
  23. DisplayOBJ = object
  24.    vSnowProne : boolean;     {does system suffer from snow}
  25.    vWidth : byte;            {no. of characters of display}
  26.    vDepth: byte;             {no. of lines of display}
  27.    vBaseOfScreen: word;      {location of video memory}
  28.    vDisplayType: tVideo;     {video display type}
  29.    vForceBW: boolean;        {uses monochrome color schemes}
  30.    {methods...}
  31.    constructor Init;
  32.    function    TestVideo: tVideo;
  33.    function    SnowProne: boolean;
  34.    function    GetMode: byte;
  35.    function    ColorOn: boolean;
  36.    function    Width: byte;
  37.    function    Depth: byte;
  38.    function    DisplayType: tVideo;
  39.    procedure   SetCondensed;
  40.    procedure   SetBW(on:boolean);
  41.    procedure   Set25;
  42.    function    BaseOfScreen:pointer;        {returns ptr to video memory}
  43.    destructor  Done;
  44. end; {DisplayOBJ}
  45.  
  46. pEquipOBJ = ^EquipOBJ;
  47. EquipOBJ = object
  48.    vMainInfo: word;
  49.    vComputerID: byte;
  50.    vRomDate: string[8];
  51.    {methods...}
  52.    constructor Init;
  53.    function    ComputerID: byte;
  54.    function    ParallelPorts: byte;
  55.    function    SerialPorts: byte;
  56.    function    FloppyDrives: byte;
  57.    function    ROMDate: string;
  58.    function    GameAdapter: boolean;
  59.    function    SerialPrinter: boolean;
  60.    function    MathChip: boolean;
  61.    destructor  Done;
  62. end; {EquipOBJ}
  63.  
  64. pMemOBJ = ^MemOBJ;
  65. MemOBJ = object
  66.    vMemInfo: word;
  67.    vMaxExtMem: word;
  68.    vMaxExpMem: word;
  69.    vEMMInstalled: boolean;
  70.    vEMMmajor: byte;
  71.    vEMMminor: byte;
  72.    {methods...}
  73.    constructor Init;
  74.    function    BaseMemory: integer;
  75.    function    EMMInstalled: boolean;
  76.    function    EMMVersionMajor: byte;
  77.    function    EMMVersionMinor: byte;
  78.    function    EMMVersion: string;
  79.    function    MaxExtMem: word;
  80.    function    MaxExpMem: word;
  81.    function    ExtMemAvail: word;
  82.    function    ExpMemAvail: word;
  83.    destructor  Done;
  84. end; {MemOBJ}
  85.  
  86. pOSOBJ = ^OSOBJ;
  87. OSOBJ = object  {Operating System}
  88.    vMajor: byte;
  89.    vMinor: byte;
  90.    vCountry: word;
  91.    vDateFmt: tDate;
  92.    vCurrency: string[5];
  93.    vThousands: byte;
  94.    vDecimal: byte;
  95.    vDateSeparator: byte;
  96.    vTimeSeparator: byte;
  97.    vTimeFmt: byte;
  98.    vCurrencyFmt: byte;
  99.    vCurrencyDecPlaces: byte;
  100.    {methods...}
  101.    constructor Init;
  102.    function OSVersionMajor: byte;
  103.    function OSVersionMinor: byte;
  104.    function OSVersion: string;
  105.    function Country: word;
  106.    function Currency: string;
  107.    function DateFmt: tDate;
  108.    function TimeFmt: byte;
  109.    function ThousandsSep: char;
  110.    function DecimalSep: char;
  111.    function DateSep: char;
  112.    function TimeSep: char;
  113.    function CurrencyFmt: byte;
  114.    function CurrencyDecPlaces: byte;
  115.    destructor  Done;
  116. end; {OSOBJ}
  117.  
  118. procedure sysINIT;
  119.  
  120. VAR
  121.   Monitor: ^DisplayObj;
  122.  
  123. IMPLEMENTATION
  124. {||||||||||||||||||||||||||||||||||||}
  125. {                                    }
  126. {     D I S P L A Y    S T U F F     }
  127. {                                    }
  128. {||||||||||||||||||||||||||||||||||||}
  129. constructor DisplayObj.Init;
  130. {}
  131. var Mode : byte;
  132. begin
  133.    vDisplayType := TestVideo;
  134.    Mode := GetMode;
  135.    if Mode = 7 then
  136.       vBaseOfScreen := $B000  {Mono}
  137.    else
  138.       vBaseOfScreen := $B800; {Color}
  139.    vSnowProne := (vDisplayType = CGA);
  140.    vWidth := 80;
  141.    vDepth := succ(Hi(WindMax));
  142.    vForceBW := false;
  143. end; {DisplayObj.Init}
  144.  
  145. function DisplayOBJ.TestVideo: tVideo;
  146. {}
  147. var
  148.    Regs: Registers;
  149.    Equip: byte;
  150.    Temp: tVideo;
  151. begin
  152.    with Regs do
  153.    begin
  154.       Al := $00;
  155.       Ah := $1A;   {get VGA info}
  156.       Intr($10,Regs);
  157.       if Al = $1A then
  158.          case Bl of
  159.          $00: Temp := unknown;
  160.          $01: Temp := Mono;
  161.          $04: Temp := EGACol;
  162.          $05: Temp := EGAMono;
  163.          $07: Temp := VGAMono;
  164.          $08: Temp := VGACol;
  165.          $0A,
  166.          $0C: Temp := MCGACol;
  167.          $0B: Temp := MCGAMono;
  168.          else
  169.             Temp := CGA;
  170.          end {case}
  171.       else         {more checking needed}
  172.       begin
  173.          Ah := $12;
  174.          BX := $10;  {get EGA data}
  175.          Intr($10,Regs);
  176.          if BX = $10 then {EGA or Mono}
  177.          begin
  178.              Intr($11,Regs);
  179.              if ((Al and $30) shr 4) = 3 then
  180.                 Temp := Mono
  181.              else
  182.                 Temp := CGA;
  183.          end
  184.          else 
  185.          begin
  186.              Ah := $12;
  187.              BX := $10;  {one more time!}
  188.              Intr($10,Regs);
  189.              if Bh = 0 then
  190.                 Temp := EGACol
  191.              else
  192.                 Temp := EGAMono;
  193.          end;  {if}
  194.       end; {if}
  195.    end; {with}
  196.    TestVideo := Temp;
  197. end; {DisplayOBJ.TestVideo}
  198.  
  199. function DisplayObj.GetMode;
  200. {}
  201. var Regs : registers;
  202. begin
  203.    with Regs do
  204.    begin
  205.       Ax := $0F00;
  206.       Intr($10,Regs);  {get video display mode}
  207.       GetMode := Al;
  208.    end;
  209. end; {DisplayObj.GetMode}
  210.  
  211. function DisplayObj.ColorOn: boolean;
  212. {}
  213. begin
  214.    if (vForceBW)
  215.    or (DisplayType in [Mono, MCGAMono, EGAMono, VGAMono])
  216.    or (GetMode = 2) then       {Mode BW80 active}
  217.       ColorOn := False
  218.    else
  219.       ColorOn := true;
  220. end; {DisplayObj.ColorOn}
  221.  
  222. procedure DisplayOBJ.SetBW(On:boolean);
  223. {}
  224. begin
  225.    vForceBW := On;
  226. end; {DisplayOBJ.SetBW}
  227.  
  228. function DisplayObj.BaseOfScreen: pointer;
  229. {}
  230. begin
  231.     BaseofScreen := ptr(vBaseOfScreen,0);
  232. end; {DisplayObj.BaseOfScreen}
  233.  
  234. function DisplayObj.SnowProne: boolean;
  235. {}
  236. begin
  237.    SnowProne := vSnowProne;
  238. end; {DisplayObj.SnowProne}
  239.  
  240. function DisplayObj.Width: byte;
  241. {}
  242. begin
  243.    Width := vWidth;
  244. end; {DisplayObj.Width}
  245.  
  246. function DisplayObj.Depth: byte;
  247. {}
  248. begin
  249.    Depth := vDepth;
  250. end; {DisplayObj.Depth}
  251.  
  252. function DisplayObj.DisplayType: tVideo;
  253. {}
  254. begin
  255.     DisplayType := vDisplayType;
  256. end; {DisplayObj.DisplayType}
  257.  
  258. procedure DisplayObj.SetCondensed;
  259. {sets to maximum number od display lines supported by the display system}
  260. begin
  261.    if vDisplayType in [EGAMono,EGACol,VGAMono,VGACol] then
  262.    begin
  263.       TextMode(Lo(LastMode)+Font8x8);
  264.       vDepth := succ(Hi(WindMax));
  265.    end;
  266. end; {DisplayObj.SetCondensed}
  267.  
  268. procedure DisplayObj.Set25;
  269. {resets display back to 25 lines}
  270. begin
  271.    if Depth <> 25 then
  272.    begin
  273.       TextMode(Lo(LastMode));
  274.       vDepth := succ(Hi(WindMax));
  275.    end;
  276. end; {DisplayObj.Set25}
  277.  
  278. destructor DisplayObj.Done;
  279. begin end;
  280.  
  281. {||||||||||||||||||||||||||||||||||||}
  282. {                                    }
  283. {       E Q U I P    S T U F F       }
  284. {                                    }
  285. {||||||||||||||||||||||||||||||||||||}
  286.  
  287. constructor EquipOBJ.Init;
  288. {}
  289. var  Reg: registers;
  290. begin
  291.    intr($11,Reg);
  292.    vMainInfo := Reg.AX;
  293.    vComputerID := mem[$F000:$FFFE];
  294.    move(mem[$F000:$FFF5],vROMDate[1],8);
  295.    vROMDate[0] := chr(8);
  296. end; {of const EquipOBJ.Init}
  297.  
  298. function EquipOBJ.ComputerID: byte;
  299. {}
  300. begin
  301.    ComputerID := vComputerID;
  302. end; {EquipOBJ.ComputerID}
  303.  
  304. function EquipOBJ.ParallelPorts: byte;
  305. {}
  306. begin
  307.    ParallelPorts := hi(vMainInfo) shr 6;
  308. end; {EquipOBJ.ParallelPorts}
  309.  
  310. function EquipOBJ.SerialPorts: byte;
  311. {}
  312. begin
  313.    SerialPorts := hi(vMainInfo) and $0F shr 1;
  314. end; {EquipOBJ.SerialPorts}
  315.  
  316. function EquipOBJ.FloppyDrives: byte;
  317. {}
  318. begin
  319.    FloppyDrives := ((vMainInfo and $C0) shr 6) + 1;
  320. end; {EquipOBJ.FloppyDrives}
  321.  
  322. function EquipOBJ.ROMDate: string;
  323. {}
  324. begin
  325.    ROMDate := vROMDate;
  326. end; {EquipOBJ.ROMDate}
  327.  
  328. function EquipOBJ.GameAdapter: boolean;
  329. {}
  330. begin
  331.    GameAdapter := ((vMainInfo and $1000) = 1);
  332. end; {EquipOBJ.GameAdapter}
  333.  
  334. function EquipOBJ.SerialPrinter: boolean;
  335. {}
  336. begin
  337.    SerialPrinter := ((vMainInfo and $2000) = 1);
  338. end; {EquipOBJ.SerialPrinter}
  339.  
  340. function EquipOBJ.MathChip: boolean;
  341. {}
  342. begin
  343.    MathChip := ((vMainInfo and $2) = $2);
  344. end; {EquipOBJ.mathChip}
  345.  
  346. destructor EquipOBJ.Done;
  347. begin end;
  348.  
  349. {||||||||||||||||||||||||||||||||}
  350. {                                }
  351. {       M E M    S T U F F       }
  352. {                                }
  353. {||||||||||||||||||||||||||||||||}
  354.  
  355. constructor MemOBJ.Init;
  356. {}
  357. const
  358.    FingerPrint: string[8] = 'EMMXXXX0';
  359. var  
  360.    Regs: registers;
  361.    ID: string[8];
  362. begin
  363.    intr($12,Regs);
  364.    vMemInfo := Regs.AX;
  365.    with regs do
  366.    begin
  367.       Ah := $35;
  368.       Al := $67;
  369.       Intr($21,Regs); {ES now points to int $67 segment -- id is 10 bytes on}
  370.       move(mem[ES:$000A],ID[1],8);
  371.       ID[0] := chr(8);
  372.       vEMMInstalled := (ID = FingerPrint);
  373.    end;
  374.    vEMMMajor := 0;
  375.    vEMMMinor := 0;
  376.    if EMMInstalled then
  377.    begin
  378.       {get total expanded memory}
  379.       Regs.Ah := $42;
  380.       intr($67,Regs);
  381.       vMaxExpMem := Regs.DX * 16;
  382.       {get driver version number}
  383.       Regs.Ah := $46;
  384.       intr($67,Regs);
  385.       if Regs.Ah = 0 then
  386.       begin
  387.           vEMMMajor := Regs.Al shr 4;
  388.           vEMMMinor := Regs.AL and $F;
  389.       end;
  390.    end
  391.    else
  392.       vMaxExpMem := 0;
  393. end; {of const MemOBJ.Init}
  394.  
  395. function MemOBJ.BaseMemory: integer;
  396. {}
  397. begin
  398.    BaseMemory := vMemInfo;
  399. end; {MemOBJ.BaseMemory}
  400.  
  401. function MemOBJ.EMMInstalled: boolean;
  402. {}
  403. begin
  404.    EMmInstalled := vEMMInstalled;
  405. end; {MemOBJ.EMMInstalled}
  406.  
  407. function MemOBJ.ExtMemAvail: word;
  408. {}
  409. var regs : registers;
  410. begin
  411.    Regs.Ah := $88;
  412.    Intr($15,Regs);
  413.    ExtMemAvail := Regs.AX;
  414. end; {MemOBJ.ExtMemAvail}
  415.  
  416. function MemOBJ.ExpMemAvail: word;
  417. {}
  418. var regs : registers;
  419. begin
  420.    if EMMInstalled then
  421.    begin
  422.       Regs.Ah := $42;
  423.       intr($67,Regs);
  424.       ExpMemAvail := Regs.BX * 16;
  425.    end
  426.    else
  427.       ExpMemAvail := 0;
  428. end; {MemOBJ.NetExpMemory}
  429.  
  430. function MemOBJ.MaxExpMem: word;
  431. {}
  432. begin
  433.    MaxExpMem := vMaxExpMem
  434. end; {MemOBJ.MaxExpMem}
  435.  
  436. function MemOBJ.MaxExtMem: word;
  437. {}
  438. begin
  439.    MaxExtMem := vMaxExtMem
  440. end; {MemOBJ.MaxExtMem}
  441.  
  442. function MemOBJ.EMMVersionMajor: byte;
  443. {}
  444. begin
  445.    EMMVersionMajor := vEMMMajor;
  446. end; {MemOBJ.EMMVersionMajor}
  447.  
  448. function MemOBJ.EMMVersionMinor: byte;
  449. {}
  450. begin
  451.    EMMVersionMinor := vEMMMinor;
  452. end; {MemOBJ.EMMVersionMinor}
  453.  
  454. function MemOBJ.EMMVersion: string;
  455. {}
  456. begin
  457.    EMMVersion := chr(EMMVersionMajor + 48)+'.'+chr(EMMVersionMinor + 48);
  458. end; {MemOBJ.EMMVersion}
  459.  
  460.  
  461. destructor MemOBJ.Done;
  462. begin end;
  463.  
  464. {||||||||||||||||||||||||||||||||}
  465. {                                }
  466. {       O. S.    S T U F F       }
  467. {                                }
  468. {||||||||||||||||||||||||||||||||}
  469. constructor OSObj.Init;
  470. {}
  471. var
  472.    Regs: registers;
  473.    CountryBuf: array[0..$21] of byte;
  474.    P: byte;
  475.    W: word absolute CountryBuf;
  476. begin
  477.    with regs do
  478.    begin
  479.       Ah := $30;
  480.       msdos(Regs);
  481.       vMajor := Al;
  482.       vMinor := Ah;
  483.       AX := $3800;
  484.       DS := seg(CountryBuf);
  485.       DX := ofs(CountryBuf);
  486.       intr($21,Regs);
  487.       vCountry := Regs.BX;
  488.       if vMajor >= 3 then
  489.       begin
  490.          vDateFmt := tDate(W);
  491.          vCurrency := '     ';
  492.          move(CountryBuf[$2],vCurrency[1],5);
  493.          P := pos(#0,vCurrency);      {ASCIIZ string form}
  494.          if P > 0 then
  495.             delete(vCurrency,P,5);
  496.          vThousands := CountryBuf[$7];
  497.          vDecimal := CountryBuf[$9];
  498.          vDateSeparator := CountryBuf[$B];
  499.          vTimeSeparator := CountryBuf[$D];
  500.          vTimeFmt := CountryBuf[$11];
  501.          vCurrencyFmt := CountryBuf[$F];
  502.          vCurrencyDecPlaces := CountryBuf[$10];
  503.       end
  504.       else
  505.       begin
  506.          vDateFmt := tDate(W);
  507.          vCurrency := chr(CountryBuf[$2]);
  508.          vThousands := CountryBuf[$04];
  509.          vDecimal := CountryBuf[$06];
  510.          vDateSeparator := ord('/');   {not avialable before DOS 3}
  511.          vTimeSeparator := ord(':');
  512.          vTimeFmt := 1;
  513.          vCurrencyFmt := 0;
  514.          vCurrencyDecPlaces := 2;
  515.       end;
  516.    end;
  517. end; {of const OSObj.Init}
  518.  
  519. function OSObj.OSVersionMajor: byte;
  520. {}
  521. begin
  522.    OSVersionMajor := vMajor;
  523. end; {OSObj.OSVersionMajor}
  524.  
  525. function OSObj.OSVersionMinor: byte;
  526. {}
  527. begin
  528.    OSVersionMinor := vMinor;
  529. end; {OSObj.OSVersionMinor}
  530.  
  531. function OSObj.OSVersion: string;
  532. {}
  533. begin
  534.    OSVersion := chr(OSVersionMajor + 48)+'.'+chr(OSVersionMinor + 48);
  535. end; {OSObj.OSVersion}
  536.  
  537. function OSObj.Country: word;
  538. {}
  539. begin
  540.    Country := vCountry;
  541. end; {OSObj.Country}
  542.  
  543. function OSObj.Currency: string;
  544. {}
  545. begin
  546.    Currency := vCurrency;
  547. end; {OSObj.Currency}
  548.  
  549. function OSObj.DateFmt: tDate;
  550. {}
  551. begin
  552.    DateFmt := vDateFmt;
  553. end; {OSObj.DateFmt}
  554.  
  555. function OSObj.ThousandsSep: char;
  556. {}
  557. begin
  558.    ThousandsSep := chr(vThousands);
  559. end; {OSObj.ThousandsSep}
  560.  
  561. function OSObj.DecimalSep: char;
  562. {}
  563. begin
  564.    DecimalSep := chr(vDecimal);
  565. end; {OSObj.DecimalSep}
  566.  
  567. function OSObj.DateSep: char;
  568. {}
  569. begin
  570.    DateSep := chr(vDateSeparator);
  571. end; {OSObj.DateSep}
  572.  
  573. function OSObj.TimeSep: char;
  574. {}
  575. begin
  576.    TimeSep := chr(vTimeSeparator);
  577. end; {OSObj.TimeSep}
  578.  
  579. function OSObj.TimeFmt: byte;
  580. {}
  581. begin
  582.    TimeFmt := vTimeFmt;
  583. end; {OSObj.TimeFmt}
  584.  
  585. function OSObj.CurrencyFmt: byte;
  586. {}
  587. begin
  588.    CurrencyFmt := vCurrencyFmt;
  589. end; {OSObj.CurrencyFmt}
  590.  
  591. function OSObj.CurrencyDecPlaces: byte;
  592. {}
  593. begin
  594.    CurrencyDecPlaces := vCurrencyDecPlaces;
  595. end; {OSObj.CurrencyDecPlaces}
  596.  
  597. destructor OSObj.Done;
  598. begin end;
  599. {|||||||||||||||||||||||||||||||||||||||||||||||}
  600. {                                               }
  601. {     U N I T   I N I T I A L I Z A T I O N     }
  602. {                                               }
  603. {|||||||||||||||||||||||||||||||||||||||||||||||}
  604. procedure SysInit;
  605. {initilizes objects and global variables}
  606. begin
  607.    new(Monitor,Init);
  608. end;
  609.  
  610. {end of unit - add intialization routines below}
  611. {$IFNDEF OVERLAY}
  612. begin
  613.    SysInit;
  614. {$ENDIF}
  615. end.
  616.  
  617.  
  618.